﻿@using CultureHelper = Mt.Site.Core.Localization.CultureHelper
@using Abp.Extensions
@{
    Layout = "";
}
<!DOCTYPE html>
<html>
<head>
    <title>打印预览</title>
    <meta charset="utf-8">
    <app-bundle asp-bundle-name="/content/build/Mt.oa.css"></app-bundle>
    <app-bundle asp-bundle-name="/content/build/Mt.lib.css" asp-is-rtl="CultureHelper.IsRtl"></app-bundle>
    <!--[if lt IE 9]>
        <script src="~/libs/respond/respond.min.js"></script>
        <script src="~/libs/html5shiv/html5shiv.js"></script>
        <script src="~/libs/excanvas/excanvas.min.js"></script>
    <![endif]-->
    <app-bundle asp-bundle-name="/content/build/Mt.lib.js"></app-bundle>
    <script type="text/javascript">
        var appModule = angular.module('app', [
            "ui.router",
            "ui.bootstrap",
            'ui.utils',
            "ui.jq",
            'ui.grid',
            'ui.grid.pagination',
            'ui.grid.treeView',
            'ui.grid.selection',
            'ui.grid.draggable-rows',
            'ui.grid.edit',
            "oc.lazyLoad",
            "ngSanitize",
            'angularFileUpload',
            'daterangepicker',
            'angularMoment',
            'frapontillo.bootstrap-switch',
            'abp',
            'ngFileUpload',
            'ng-pagination',
            'ngMap'
        ]).config(['$compileProvider', function ($compileProvider) {
            angular.lowercase = angular.$$lowercase;
            angular.uppercase = angular.$$uppercase;
            $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|itms\-apps|ftp|mailto|javascript):/);
        }]);
    </script>
    <script src="/AbpScripts/GetScripts?minify=true" type="text/javascript"></script>
    <script src="/AbpServiceProxies/GetAll?type=angularjs&v=@(DateTime.Now.Ticks)"></script>
    @*<script type="text/javascript" src="~/Mt/common/services/appHttpUtilityHelper.js"></script>
        <script type="text/javascript" src="~/Mt/common/services/workflowHelper.js"></script>
        <script type="text/javascript" src="~/Mt/common/directives/uploadFlowFile.js"></script>
        <script type="text/javascript" src="~/Mt/common/directives/mulFlowUpload.js"></script>*@
    <app-bundle asp-bundle-name="/content/build/common.js"></app-bundle>
    <app-bundle asp-bundle-name="/content/build/Mt.js"></app-bundle>
    <app-bundle asp-bundle-name="/content/build/Mt.oa.js"></app-bundle>
</head>
<body style="overflow-y:scroll" class="page-print">
    <div ng-app="app" style="width:1080px;">
        <section class="content no-padding" ng-controller="myCtrl as vm">
            <div class="page-workEdit" busy-if="vm.loading">
                <div class="workEdit-box">
                    <div class="workEdit-inner">
                        <!-- <div class="workEdit-titbox">
                            <div class="normal-tit" ng-show="!vm.isTitleEdit">
                                <h2 class="tit">{{vm.workFlowData.title}}</h2>
                            </div>
                        </div> -->
                        <div class="row2">
                            <div class="tab-content editTxt-bd">
                                <div class="tab-pane fade in active pane-editTxt" id="txt1">
                                    <div class="container" style="padding:0 63px;">
                                        <div class="global-form-box frm-editTxt-box">
                                            <!-- 基本信息 start -->
                                            <div class="editTxt-sec editTxt-baseInfo" ng-show="vm.formCk">
                                                <div class="form-box" style="font-family:SimSun;font-size:20px;line-height: 30px;color:#333;padding: 30px 0;">
                                                    <div class="w954" style="width:100%;" id="formdata">

                                                    </div>
                                                </div>
                                            </div>
                                            <!-- 基本信息 end -->
                                            <!-- 起草正文 start -->
                                            <div class="editTxt-sec editTxt-qczw" ng-if="vm.workFlowData.isHaveOnlineWord" ng-show="vm.onlineWord">
                                                <h4 class="sec-tit"><img src="~/content/images_N/icon_edit.png" />起草正文</h4>
                                                <div class="sec-bd">
                                                    <a href ng-click="vm.openOnlineFile()" class="btn-build">在线编辑</a>
                                                </div>
                                            </div>
                                            <!-- 起草正文 end -->
                                            <!-- 附件 start -->
                                            <div class="editTxt-sec editTxt-attach" ng-show="vm.fujian" ng-if="false">
                                                <h4 class="sec-tit"><img src="~/content/images_N/icon_fj.png" />附件</h4>
                                                <div class="sec-bd">
                                                    <mul-flow-upload content-id="{{vm.paperId}}" custom-key="workFlowMultieFiles" can-edit="{{vm.canEditAttach}}"></mul-flow-upload>
                                                </div>
                                            </div>
                                            <!-- 附件 end -->
                                        </div>
                                    </div>
                                </div>
                                <!-- txt1 end -->
                            </div>

                            <div class="pflow-inner" ng-show="vm.opinion" style="margin-bottom: 30px;">
                                <h4 class="sec-tit">流程轨迹</h4>
                                <div class="flow-step-table">
                                    <div class="tr" ng-repeat="item in vm.remarkData">
                                        <div class="th"><span class="step"></span>{{item.nodeName}}</div>
                                        <div class="td">
                                            <ul class="flow-audit">
                                                <li style="padding-left:{{x.lv * 20}}px;" class="dont" ng-repeat="x in item.data">
                                                    <div class="hd">
                                                        <div class="info tit">{{x.userName}}<span>[{{vm.checkState(x)}}{{vm.timeDiffCalc(x.state,x.markedTime,x.finishedTime)}}]</span></div>
                                                    </div>
                                                    <div class="bd">
                                                        <div class="info time" ng-if="x.markedTime">开始于：{{x.markedTime}}</div>
                                                        <div class="info time" ng-if="x.state === 2  && x.finishedTime">结束于：{{x.finishedTime}}</div>
                                                        <div class="info opinion" ng-if="x.reply">{{x.reply}}</div>
                                                    </div>
                                                </li>
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="lcrz-table" ng-show="vm.logs" style="margin-bottom: 30px;">
                                <h4 class="sec-tit">流程日志</h4>
                                <table cellpadding="0" cellspacing="0">
                                    <thead>
                                        <tr>
                                            <th class="th1">处理人</th>
                                            <th class="th2">处理时间</th>
                                            <th class="th3">操作</th>
                                            <th class="th4">受理人</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr ng-repeat="item in vm.workFlowData.logData">
                                            <td class="th1"><span>{{item.fromOperator}}</span></td>
                                            <td class="th2">
                                                <span>{{vm.timeFormat(item.creationTime)}}</span>
                                            </td>
                                            <td class="th3">
                                                <span>{{item.message}}</span>
                                            </td>
                                            <td class="th4">
                                                <span>{{item.nextOperator}}</span>
                                            </td>

                                        </tr>
                                    </tbody>
                                </table>
                            </div>

                            <div class="lcrz-table detailModal-attach"  ng-show="vm.fujian" style="margin-bottom: 30px;">
                                <h4 class="sec-tit">附件</h4>
                                <table cellpadding="0" cellspacing="0">
                                    <thead>
                                        <tr>
                                            <th class="th1">标题</th>
                                            <th class="th2">上传人员</th>
                                            <th class="th3">上传时间</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr ng-repeat="item in vm.fileAttachs">
                                            <td class="th1">
                                                <span>
                                                    <img src="/content/images_N/202005/icon_attach2.png" height="15" style="margin: -3px 4px 0 0;">
                                                    <a ng-click="vm.downAttach(item.filePath)" href="javascript:void(0)">{{item.fileName}}({{item.fileSize}})</a>
                                                </span>
                                            </td>
                                            <td class="th2">
                                                <span>{{item.userName}}</span>
                                            </td>
                                            <td class="th3">
                                                <span>{{item.creationTime | date:'yyyy-MM-dd HH:mm'}}</span>
                                            </td>

                                        </tr>
                                    </tbody>
                                </table>
                            </div>

                            <div class="lcrz-table detailModal-attach"  ng-show="vm.cuiBanjiLu && vm.workFlowData.wfUniqueName == vm.wfUniqueName.bj" style="margin-bottom: 30px;">
                                <h4 class="sec-tit">催办记录</h4>
                                <table cellpadding="0" cellspacing="0">
                                    <thead>
                                        <tr>
                                            <th class="th2">催办人</th>
                                            <th class="th2">被催人</th>
                                            <th class="th3">催办时间</th>
                                            <th class="th2">读取情况</th>
                                            <th class="th3">读取时间</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr ng-repeat="item in vm.bjCuiBanData.items">
                                            <td class="th2">
                                                <span>{{vm.bjCuiBanData.senderName}}</span>
                                            </td>
                                            <td class="th2">
                                                <span>{{item.userInfo.userName}}</span>
                                            </td>
                                            <td class="th3">
                                                <span>{{item.notification.creationTime | date:'yyyy-MM-dd HH:mm'}}</span>
                                            </td>
                                            <td class="th2">
                                                <span>{{(item.state==0?'未读':'已读')}}</span>
                                            </td>
                                            <td class="th3">
                                                <span>{{item.readTime | date:'yyyy-MM-dd HH:mm'}}</span>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                    <!-- editTxt-ft start -->
                    <div class="editTxt-ft" ng-if="vm.toolbarShow" style="margin-bottom:10px;">
                        <ul class="tool-box fl">
                            <li>
                                <a href="javascript:void(0)" ng-click="vm.print()"><img src="~/content/images_N/icon_print.png" />打印表单</a>
                            </li>
                        </ul>
                        <div class="btn-box fr">
                            <label for="ck1"><input type="checkbox" ng-checked="vm.formCk" ng-click="vm.formCk=!vm.formCk" id="ck1" /> &nbsp;表单</label>
                            &nbsp;&nbsp;&nbsp;<label ng-if="vm.workFlowData.isHaveOnlineWord" for="ck2"><input type="checkbox" ng-checked="vm.onlineWord" ng-click="vm.onlineWord=!vm.onlineWord" id="ck2" /> &nbsp;在线word</label>
                            &nbsp;&nbsp;&nbsp;<label for="ck4"><input type="checkbox" ng-checked="vm.opinion" ng-click="vm.opinion=!vm.opinion" id="ck4" /> &nbsp;轨迹</label>
                            &nbsp;&nbsp;&nbsp;<label for="ck5"><input type="checkbox" ng-checked="vm.logs" ng-click="vm.logs=!vm.logs" id="ck5" /> &nbsp;日志</label>
                            &nbsp;&nbsp;&nbsp;<label for="ck3"><input type="checkbox" ng-checked="vm.fujian" ng-click="vm.fujian=!vm.fujian" id="ck3" /> &nbsp;附件</label>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </div>
    
    <script type="text/javascript">
        abp.security.antiForgery.tokenCookieName = "Public-XSRF-TOKEN";
        abp.security.antiForgery.tokenHeaderName = "Public-X-XSRF-TOKEN";

        appModule.controller('myCtrl', ['$scope', 'abp.services.app.archive', 'abp.services.app.workFlow', '$compile', 'appHttpUtilityHelper', 'workflowHelper'
            , 'abp.services.app.notification', 'abp.services.app.workFlowFileUpload',
                function ($scope, archiveService, workFlowService, $compile, appHttpUtilityHelper, workflowHelper, mtNotificationService,workFlowFileUpload) {
                    var vm = this;
                    vm.paperId = '@ViewBag.paperId';
                    vm.archived =@(ViewBag.archived == 1?"true":"false");

                    vm.workFlowData = {};
                    vm.remarkData = [];         //流程轨迹
                    vm.passRoundData = [];      //传阅记录
                    vm.data = {};               //表单字段数据
                    vm.fieldDisabled = {};      //表单字段是否可编辑
                    vm.canEditAttach = false;
                    vm.paperState = -1;
                    vm.isTitleEdit = false;
                    vm.toolbarShow = true;

                    vm.formCk = true;
                    vm.onlineWord = false;
                    vm.fujian = false;
                    vm.cuiBanjiLu = false;

                    vm.opinion = false;
                    vm.logs = false;
                    vm.wfUniqueName = {
                        bj: '收文办件',
                        yj: '收文阅件',
                        yglh: '因公离杭'
                    };
                    var serviceName = workFlowService.getDataForPrint;
                    if (vm.archived) {
                        serviceName = archiveService.getDataForPrint;
                    }

                    vm.getFlowWorkData = function () {
                        if (vm.paperId) {
                            serviceName({ paperId: vm.paperId }).then(function (result) {
                                vm.workFlowData = result.data;
                                vm.paperState = vm.workFlowData.paperState;
                                vm.canEditAttach = vm.workFlowData.canEditAttachment;
                                vm.data = result.data.formData.data;
                                vm.remarkData = workflowHelper.getRemarkData(vm.workFlowData.remarkData);
                                vm.passRoundData = workflowHelper.getPassRoundData(vm.workFlowData.remarkData);

                                vm.fieldDisabled = result.data.formData.fieldDisabled;
                                var htmlStr = appHttpUtilityHelper.htmlDecode(result.data.formHtml);
                                var compileFn = $compile(htmlStr);
                                // 传入scope，得到编译好的dom对象(已封装为jqlite对象)
                                // 也可以用$scope.$new()创建继承的作用域
                                var $dom = compileFn($scope);
                                // 添加到文档中
                                $dom.appendTo(document.getElementById('formdata'));

                                //loadNoticeList();
                                getFileAttachs(vm.workFlowData.paper.id);

                                setTimeout(function () {
                                    $("#formdata :text,textarea").each(function () {
                                        var val = $(this).val();
                                        $(this).parent().css("text-align", "left");
                                        $(this).hide().after("<span>" + val + "</span>");
                                    });
                                    //隐藏按钮
                                    $("#formdata button").hide();
                                    $("#formdata input[type='checkbox']").css("-webkit-appearance", "checkbox");
                                    $("#formdata input[type='radio']").css("-webkit-appearance", "radio");
                                }, 800);
                            });
                        }
                    };

                    vm.getFlowWorkData();

                    vm.checkState = function (data) {
                        return workflowHelper.checkState(data);
                    };

                    vm.timeFormat = function (time) {
                        return workflowHelper.timeFormat(time);
                    };

                    vm.timeDiffCalc = function (state, markTime, finishedTime) {
                        return workflowHelper.timeDiffCalc(state, markTime, finishedTime);
                    };

                    // 催办列表数据加载
                    vm.noticeData = { yue: [], ban: [] };
                    function loadNoticeList() {
                        if (vm.passRoundData.length > 0 || (vm.workFlowData.paper && vm.workFlowData.paper.mainOperativeUserId)) {
                            mtNotificationService.getUserNotificationsByEntityId({ paperId: vm.paperId }).then(function (result) {
                                if (result.data.items.length > 0) {
                                    var newData = { yue: [], ban: [] };

                                    $.each(result.data.items, function (index, item) {
                                        if (item.notification.notificationName === "App.Bj.Reminder") {
                                            item.senderName = item.notification.data.properties.senderName;
                                            newData.ban.push(item);
                                        } else if (item.notification.notificationName === "App.Yue.Reminder") {
                                            item.senderName = item.notification.data.properties.senderName;
                                            newData.yue.push(item);
                                        }
                                    });

                                    vm.noticeData = newData;
                                }
                            });
                        }
                    }

                    vm.fileAttachs = [];
                    function getFileAttachs(paperId) {
                        vm.loading = true;
                        workFlowFileUpload.getWorkFlowFiles({ id: paperId }).then(function (result) {
                            vm.fileAttachs = result.data;
                        }).finally(function () {
                            vm.loading = false;
                        });
                    }

                    vm.print = function () {
                        vm.toolbarShow = false;
                        setTimeout(function () {
                            window.focus();
                            window.print();
                            window.close();
                        }, 300);
                    };
                }
            ]);
    </script>
</body>
</html>

